<?php
error_reporting(0);
session_start();

include_once '../comm/config.php';
include_once '../comm/class.phpmailer.php';
include_once '../comm/wjt.php';
$tag="center";

$str=trim($_GET['str']); 
if($str==''){
	header('Location: error1.php?id=18');
	exit;
}
$mingma_str=base64_decode($str);
$array_result = explode('*',$mingma_str);

include_once '../comm/checkpostandget.php';
FunStringExist($array_result,$ArrFiltrate);
if(time()-$array_result[2]>600){
    header('Location: error1.php?id=33'); //超时
	exit;
}
$q = "SELECT * FROM ".$BIAOTOU."user where ddusername='".$array_result[0]."' limit 1";
$rs = mysql_query($q);
$row = mysql_fetch_object($rs);
if($row->ddusername=='')
{
	header('Location: error1.php?id=3');
	exit;
}
else
{
	$ddusername=$row->ddusername; 
	$ddpassword=$row->ddpassword; 
	
	$x = md5($ddusername.'+'.$ddpassword);
	if($x!=$array_result[1]){
		header('Location: error.php?id=19');
		exit;
	}
}    
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<title>找回密码 - 用户中心</title>

<link href="../template/<?=MOBAN?>/css/style.css" rel="stylesheet" type="text/css" />
<link  href="../template/<?=MOBAN?>/css/layout.css" rel="stylesheet" type="text/css" />
<link  href="../template/<?=MOBAN?>/css/comm.css" rel="stylesheet" type="text/css" />
<link  href="../template/<?=MOBAN?>/css/error.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="../js/jquery.js"></script>
<script type="text/javascript">
function getLength(str) {
    var len = str.length;
    var reLen = 0;
    for (var i = 0; i < len; i++) {        
        if (str.charCodeAt(i) < 27 || str.charCodeAt(i) > 126) {
            // 全角    
            reLen += 2;
        } else {
            reLen++;
        }
    }
    return reLen;    
} 
function checkpass(password)
{
    	if(getLength(password)<6 || getLength(password)>20)
		{
			document.getElementById("ckpass").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>密码长度必须为 6 - 20 位</font>';
		}
		else
		{
			document.getElementById("ckpass").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>密码填写正确</font>';
		}
}    

function checkpass2()
{
    	if(getLength(document.getElementById("password_check").value)<6 || getLength(document.getElementById("password_check").value)>20)
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>密码长度必须为 6 - 20 位</font>';
			return false;
		}
		else if (document.getElementById("password").value!=document.getElementById("password_check").value)
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/cuo.gif alt="错误" align=absmiddle /> <font color=#ff0000>两次密码输入不一致！</font>';
			return false;
		}
		else
		{
			document.getElementById("ckpass2").innerHTML = '<img src=../images/dui.gif alt="正确" align=absmiddle /> <font color=#009900>密码再次确认正确</font>';
			return true;
		}
}   
function checkall()
{
	if(document.getElementById("password").value==""||!checkpass2())
	{
		alert('请填写完内容！');
		return false;
	}
	else
	{
		return true;
	}
} 

function tip(id)
{
	if(id==1)
	{
		document.getElementById("tipnav").style.display="block";
	}
	if(id==2)
	{
		document.getElementById("tipnav").style.display="none";
	}
}

function tip1()
{
$("#tipnav").bind("mouseleave",
function()
{
		document.getElementById("tipnav").style.display="none";
}
);
}

function doEnter()
{
	document.getElementById("pw1").style.display="none";
	document.getElementById("password_check").style.display="block";
	document.getElementById("password_check").focus();
}
</script>
</head>
<body>
<div class='head_warpC'>
	<div class='slideup layout_head'>
	<ul class="headerTopLeft">
       <li class="home"><a href="../index.php" onmousemove="tip(1);">优米库首页</a></li>
       <li><a href="../comm/shortcut.php">放到桌面</a></li>
       <li><a href="#dd" onClick="AddFavorite('<?=$navheadurl?>','<?=WEBNICK?>')">添加到收藏夹</a></li>
       <li><a href="msg_list.php?act=send">咨询优助手</a></li>
       <li><a href="msg_list.php?act=send">提意见给客服</a></li>
    </ul>

    <ul class="headerTopRight FRight">
        <li class="HUserimg"><img src="../upload/avatar/<?=get_avatar_filepath($_SESSION['dduserid'], $size = 'big')?>" width="40" height="40"></li>
        <li><a href="center.php">我的优米库</a></li>
        <li><a href="register.php">成为米粒</a></li>
        <li><a href="login.php">登录</a></li>
        <li><a href="center.php">您好，游客001</a></li>
  </ul>
  
<div class="clears"></div>
</div>  

    <div class="dhmenu" id="tipnav" onmouseout="tip1();" style="display:none">
        <div class="fm">
        <a class="active">攒米</a><a href='../malllist.php'>返米店铺</a><!--<a href='#'>返米宝</a>--><a href='tuiguang_url.php'>免费攒米</a><!--<a href='#'>省钱检测</a>--><a class="active">兑换</a><a href="../huan.php">用米兑换</a><a href="tixian.php">申请提现</a>
        <a href='#' class="active">社区</a><a href='../baobeilist.php'>米粒晒吧</a>
        <br /><a class="active">店铺</a><a href='#'>优米联盟</a>
       </div>
   </div>

<div class="quickNav"> </div>
   <div class="layout_head reg">
   <a href="../index.php" class="logo_reg"><img src="../template/<?=MOBAN?>/images/logo_zhuce.png" width="226" height="57" /></a>
    <ul class="reg_enter" style="margin-top:40px">
    <li><img src="../template/<?=MOBAN?>/images/zhaohuimim.gif" width="101" height="24" /></li>
    <li><a href="login.php">登录</a></li>
    <li><a href="register.php">创建账号</a></li>
    </ul>
    </div>
</div>

<div class="center">
 <div class="line"><font style="font-size:14px;color:#bf0000"><b>您好，游客001</b></font></div>
 <form id="form1" name="form1" method="post" action="save_resetpass.php" onsubmit="return checkall()">
 <div class="line" style="height:40px">
    <input type="text" onfocus="this.value='';this.type='password';" value="这里输入密码"  name="password" id="password" onblur="checkpass(document.getElementById('password').value);" size="20" maxlength="20" style="width:300px"  class="txtstyle" />
   <div class="hint" id="ckpass"></div>
 </div>
 <div class="line" style="height:20px;margin-top:1px;line-height:20px">密码：必填</div>
 <div class="line" style="height:40px;margin-top:30px">
   <input name="pw1" type="text" id="pw1" onfocus="doEnter();"  value="再次输入密码"  size="20" maxlength="20" style="width:300px;" class="txtstyle"/>
   <input name="password2" type="password" id="password_check"  value=""  onblur="checkpass2();"  size="20" maxlength="20" style="width:300px;display:none" class="txtstyle"/>
   <div class="hint" id="ckpass2"></div>
 </div>
 <div class="line" style="height:20px;margin-top:1px;line-height:20px">再次输入密码：必填</div>

 <input type="hidden" name="x" value="<?=$x?>" />
 <input type="hidden" name="ddusername" value="<?=$array_result[0]?>" />
 <div class="line" style="margin-top:30px">
 	<input type="submit" value="" class="cpassbutton" style="font-family:黑体;font-size:25px;font-weight:bold" />
 </div>
 </form>

 <div class="lclear"></div>
</div>
<?php
include("../template/".MOBAN."/footer.tpl.php");
?>
</body>
</html>
